package demo1;

/**
 * @Author 12629
 * @Description：
 */
class Food {
}
class Fruit extends Food {
}
class Apple extends Fruit {
}
class Banana extends Fruit {
}
class Plate<T> {
    private T val;

    public T getVal() {
        return val;
    }

    public void setVal(T val) {
        this.val = val;
    }
}
public class TestDemo2 {
    public static void main(String[] args) {
        Plate<Apple> plate1 = new Plate<>();
        plate1.setVal(new Apple());
        func(plate1);

        Plate<Banana> plate2 = new Plate<>();
        plate2.setVal(new Banana());
        func(plate2);

        Plate<Food> plate3 = new Plate<>();
        func2(plate3);
    }
    public static void func(Plate<? extends Fruit> plate) {

    }
    public static void func2(Plate<? super Fruit> plate) {
        plate.setVal(new Apple());
        plate.setVal(new Banana());
        //Fruit fruit = (Fruit)plate.getVal();
        //Object fruit = plate.getVal();
    }

}
